#!/usr/bin/env node


const https=require('http'),
      log=console.log,
      url=require('url');


const addr='https//api.github.com/search/repositories?q=user:'+(process.argv[2] || 'fumei'),
      options=url.parse(addr);
      

options.headers={
  'User-Agent':'02-get-repos.js'
};

https.get(options,opt,(res)=>{
  let data='';
  res.on('data',(chunk)=>data+=chunk);
  res.on('end',()=>{
    let rs=[],num=1;
    data=JSON.parse(data).items;
    data.forEach((item)=>{
      rs.push({
        num:num++,
        name:item.name,
        description:item.description
      });
    });
    console.table(rs);
  });
});
